package net.sourceforge.jweb.jstl.easyui;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;

import net.sourceforge.jweb.annotation.Attribute;
import net.sourceforge.jweb.annotation.Tag;

/**
 * grid的底部自定义按钮
 * 
 * @author maoanapex88@163.com alexmao86
 *
 */
@Tag(name = "gridButton", description = "datagrid button tag, used to custom function buttons at bottom")
public class GridButtonTag extends BodyTagSupport {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String iconCls;

	public int doEndTag() throws JspException {
		String bodyText = bodyContent.getString();
		StringBuilder builder = new StringBuilder();
		builder.append("{iconCls:'").append(this.iconCls).append("',handler:function(){").append(bodyText).append("}}");
		DataGridTag parentTag = (DataGridTag) this.getParent();
		parentTag.customButtons.add(builder.toString());
		return EVAL_PAGE;
	}

	@Attribute(required = true, description = "the icon class used, for example icon-excel")
	public final String getIconCls() {
		return iconCls;
	}

	public final void setIconCls(String iconCls) {
		this.iconCls = iconCls;
	}

}
